package uz.rt.dicom.dictionary;

import uz.rt.dicom.uid.SOPClass;
import uz.rt.dicom.uid.UidType;

/**
 * Dicom dictionary SOP class tag
 *
 * @see SOPClass
 * @see IDictionaryItem
 */
public class DictionarySopclassTag implements IDictionaryItem<String, UidType>
{
// ------------------------------ FIELDS ------------------------------

    /** SOP class */
    private final SOPClass sopClass;

// --------------------------- CONSTRUCTORS ---------------------------

    /**
     * Creates a new dictionary SOP class tag
     *
     * @param uid  Unique identifier
     * @param name Name of the SOP class
     */
    public DictionarySopclassTag(String uid, String name)
    {
        sopClass = new SOPClass(uid, name);
    }

// ------------------------ CANONICAL METHODS ------------------------

    @Override
    public boolean equals(Object o)
    {
        if (this == o) return true;
        if (!(o instanceof DictionarySopclassTag)) return false;

        DictionarySopclassTag that = (DictionarySopclassTag) o;

        return !(sopClass != null ? !sopClass.equals(that.sopClass) : that.sopClass != null);
    }

    @Override
    public int hashCode()
    {
        return sopClass != null ? sopClass.hashCode() : 0;
    }

// ------------------------ INTERFACE METHODS ------------------------


// --------------------- Interface IDictionaryItem ---------------------

    public String getKey()
    {
        return sopClass.getUid();
    }

    public String getName()
    {
        return sopClass.getName();
    }

    public UidType getType()
    {
        return UidType.SOPCLASS;
    }
}
